package com.zezheng.qian.project.base.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zezheng.qian.framework.aspectj.lang.annotation.Log;
import com.zezheng.qian.framework.aspectj.lang.enums.BusinessType;
import com.zezheng.qian.project.base.domain.BSeal;
import com.zezheng.qian.project.base.service.IBSealService;
import com.zezheng.qian.framework.web.controller.BaseController;
import com.zezheng.qian.framework.web.domain.AjaxResult;
import com.zezheng.qian.common.utils.poi.ExcelUtil;
import com.zezheng.qian.framework.web.page.TableDataInfo;

/**
 * 安心签印章Controller
 *
 * @author cuijie
 * @date 2023-10-23
 */
@RestController
@RequestMapping("/base/seal")
public class BSealController extends BaseController
{
    @Autowired
    private IBSealService bSealService;

    /**
     * 查询安心签印章列表
     */
    @PreAuthorize("@ss.hasPermi('base:seal:list')")
    @GetMapping("/list")
    public TableDataInfo list(BSeal bSeal)
    {
        startPage();
        List<BSeal> list = bSealService.selectBSealList(bSeal);
        return getDataTable(list);
    }

    /**
     * 导出安心签印章列表
     */
    @PreAuthorize("@ss.hasPermi('base:seal:export')")
    @Log(title = "安心签印章", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BSeal bSeal)
    {
        List<BSeal> list = bSealService.selectBSealList(bSeal);
        ExcelUtil<BSeal> util = new ExcelUtil<BSeal>(BSeal.class);
        return util.exportExcel(list, "安心签印章数据");
    }

    /**
     * 获取安心签印章详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:seal:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bSealService.selectBSealById(id));
    }

    /**
     * 新增安心签印章
     */
    @PreAuthorize("@ss.hasPermi('base:seal:add')")
    @Log(title = "安心签印章", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BSeal bSeal)
    {
        return toAjax(bSealService.insertBSeal(bSeal));
    }

    /**
     * 修改安心签印章
     */
    @PreAuthorize("@ss.hasPermi('base:seal:edit')")
    @Log(title = "安心签印章", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BSeal bSeal)
    {
        return toAjax(bSealService.updateBSeal(bSeal));
    }

    /**
     * 删除安心签印章
     */
    @PreAuthorize("@ss.hasPermi('base:seal:remove')")
    @Log(title = "安心签印章", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bSealService.deleteBSealByIds(ids));
    }
}
